<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>os Node.js v0.10.35 Manual &amp; Documentation</title>
  <link rel="stylesheet" href="assets/style.css">
  <link rel="stylesheet" href="assets/sh.css">
  <link rel="canonical" href="http://nodejs.org/api/os.html">
  <script type="text/javascript" src="//use.typekit.net/mse5tqx.js"></script>
  <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
</head>
<body class="alt apidoc int docs" id="docs">
    <div id="nav">
      <img id="logo" src="assets/logo.svg" alt="node.js">
      <ul>
        <li><a href="http://nodejs.org">Home</a></li>
        <li><a href="http://nodejs.org/download/">Downloads</a></li>
        <li class="active"><a href="http://nodejs.org/documentation/">Docs</a></li>
        <li><a href="http://nodejs.org/community/">Community</a></li>
        <li><a href="http://nodejs.org/about/">About</a></li>
        <li><a href="http://jobs.nodejs.org">Jobs</a></li>
        <li><a href="http://blog.nodejs.org">Blog</a></li>
      </ul>
    </div>
    <div id="content-wrap">
    <div id="content" class="clearfix">
      <div id="column2" class="interior">
        <!--<img src="/images/logo-light.svg" alt="node.js" width="170">-->
        <ul class="docs-nav">
          <li><a href="http://nodejs.org/documentation/">About Docs</a></li>
          <li><a href="http://nodejs.org/documentation/tutorials/">Tutorials</a></li>
          <li><a href="http://nodejs.org/documentation/contributing/">Contributing</a></li>
          <li><a href="http://nodejs.org/documentation/localization/">Localization</a></li>
          <li class="active"><a href="http://nodejs.org/api/">API Docs</a></li>
        </ul>
      </div>
        <div id="column1" class="interior">
          <header>
            <h1>Node.js v0.10.35 Manual &amp; Documentation</h1>
            <div id="gtoc">
              <p>
                <a href="index.html" name="toc">Index</a> |
                <a href="all.html">View on single page</a> |
                <a href="os.json">View as JSON</a>
              </p>
            </div>
            <hr>
          </header>

          <div id="toc">
            <h2>Table of Contents</h2>
            <ul>
<li><a href="#os_os">os</a><ul>
<li><a href="#os_os_tmpdir">os.tmpdir()</a></li>
<li><a href="#os_os_endianness">os.endianness()</a></li>
<li><a href="#os_os_hostname">os.hostname()</a></li>
<li><a href="#os_os_type">os.type()</a></li>
<li><a href="#os_os_platform">os.platform()</a></li>
<li><a href="#os_os_arch">os.arch()</a></li>
<li><a href="#os_os_release">os.release()</a></li>
<li><a href="#os_os_uptime">os.uptime()</a></li>
<li><a href="#os_os_loadavg">os.loadavg()</a></li>
<li><a href="#os_os_totalmem">os.totalmem()</a></li>
<li><a href="#os_os_freemem">os.freemem()</a></li>
<li><a href="#os_os_cpus">os.cpus()</a></li>
<li><a href="#os_os_networkinterfaces">os.networkInterfaces()</a></li>
<li><a href="#os_os_eol">os.EOL</a></li>
</ul>
</li>
</ul>

          </div>

          <div id="apicontent">
            <h1>os<span><a class="mark" href="#os_os" id="os_os">#</a></span></h1>
<pre class="api_stability_4">Stability: 4 - API Frozen</pre><p>Provides a few basic operating-system related utility functions.

</p>
<p>Use <code>require(&#39;os&#39;)</code> to access this module.

</p>
<h2>os.tmpdir()<span><a class="mark" href="#os_os_tmpdir" id="os_os_tmpdir">#</a></span></h2>
<p>Returns the operating system&#39;s default directory for temp files.

</p>
<h2>os.endianness()<span><a class="mark" href="#os_os_endianness" id="os_os_endianness">#</a></span></h2>
<p>Returns the endianness of the CPU. Possible values are <code>&quot;BE&quot;</code> or <code>&quot;LE&quot;</code>.

</p>
<h2>os.hostname()<span><a class="mark" href="#os_os_hostname" id="os_os_hostname">#</a></span></h2>
<p>Returns the hostname of the operating system.

</p>
<h2>os.type()<span><a class="mark" href="#os_os_type" id="os_os_type">#</a></span></h2>
<p>Returns the operating system name.

</p>
<h2>os.platform()<span><a class="mark" href="#os_os_platform" id="os_os_platform">#</a></span></h2>
<p>Returns the operating system platform.

</p>
<h2>os.arch()<span><a class="mark" href="#os_os_arch" id="os_os_arch">#</a></span></h2>
<p>Returns the operating system CPU architecture.

</p>
<h2>os.release()<span><a class="mark" href="#os_os_release" id="os_os_release">#</a></span></h2>
<p>Returns the operating system release.

</p>
<h2>os.uptime()<span><a class="mark" href="#os_os_uptime" id="os_os_uptime">#</a></span></h2>
<p>Returns the system uptime in seconds.

</p>
<h2>os.loadavg()<span><a class="mark" href="#os_os_loadavg" id="os_os_loadavg">#</a></span></h2>
<p>Returns an array containing the 1, 5, and 15 minute load averages.

</p>
<p>The load average is a measure of system activity, calculated by the operating
system and expressed as a fractional number.  As a rule of thumb, the load
average should ideally be less than the number of logical CPUs in the system.

</p>
<p>The load average is a very UNIX-y concept; there is no real equivalent on
Windows platforms.  That is why this function always returns <code>[0, 0, 0]</code> on
Windows.

</p>
<h2>os.totalmem()<span><a class="mark" href="#os_os_totalmem" id="os_os_totalmem">#</a></span></h2>
<p>Returns the total amount of system memory in bytes.

</p>
<h2>os.freemem()<span><a class="mark" href="#os_os_freemem" id="os_os_freemem">#</a></span></h2>
<p>Returns the amount of free system memory in bytes.

</p>
<h2>os.cpus()<span><a class="mark" href="#os_os_cpus" id="os_os_cpus">#</a></span></h2>
<p>Returns an array of objects containing information about each CPU/core
installed: model, speed (in MHz), and times (an object containing the number of
milliseconds the CPU/core spent in: user, nice, sys, idle, and irq).

</p>
<p>Example inspection of os.cpus:

</p>
<pre><code>[ { model: &#39;Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz&#39;,
    speed: 2926,
    times:
     { user: 252020,
       nice: 0,
       sys: 30340,
       idle: 1070356870,
       irq: 0 } },
  { model: &#39;Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz&#39;,
    speed: 2926,
    times:
     { user: 306960,
       nice: 0,
       sys: 26980,
       idle: 1071569080,
       irq: 0 } },
  { model: &#39;Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz&#39;,
    speed: 2926,
    times:
     { user: 248450,
       nice: 0,
       sys: 21750,
       idle: 1070919370,
       irq: 0 } },
  { model: &#39;Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz&#39;,
    speed: 2926,
    times:
     { user: 256880,
       nice: 0,
       sys: 19430,
       idle: 1070905480,
       irq: 20 } },
  { model: &#39;Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz&#39;,
    speed: 2926,
    times:
     { user: 511580,
       nice: 20,
       sys: 40900,
       idle: 1070842510,
       irq: 0 } },
  { model: &#39;Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz&#39;,
    speed: 2926,
    times:
     { user: 291660,
       nice: 0,
       sys: 34360,
       idle: 1070888000,
       irq: 10 } },
  { model: &#39;Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz&#39;,
    speed: 2926,
    times:
     { user: 308260,
       nice: 0,
       sys: 55410,
       idle: 1071129970,
       irq: 880 } },
  { model: &#39;Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz&#39;,
    speed: 2926,
    times:
     { user: 266450,
       nice: 1480,
       sys: 34920,
       idle: 1072572010,
       irq: 30 } } ]</code></pre>
<h2>os.networkInterfaces()<span><a class="mark" href="#os_os_networkinterfaces" id="os_os_networkinterfaces">#</a></span></h2>
<p>Get a list of network interfaces:

</p>
<pre><code>{ lo0: 
   [ { address: &#39;::1&#39;, family: &#39;IPv6&#39;, internal: true },
     { address: &#39;fe80::1&#39;, family: &#39;IPv6&#39;, internal: true },
     { address: &#39;127.0.0.1&#39;, family: &#39;IPv4&#39;, internal: true } ],
  en1: 
   [ { address: &#39;fe80::cabc:c8ff:feef:f996&#39;, family: &#39;IPv6&#39;,
       internal: false },
     { address: &#39;10.0.1.123&#39;, family: &#39;IPv4&#39;, internal: false } ],
  vmnet1: [ { address: &#39;10.99.99.254&#39;, family: &#39;IPv4&#39;, internal: false } ],
  vmnet8: [ { address: &#39;10.88.88.1&#39;, family: &#39;IPv4&#39;, internal: false } ],
  ppp0: [ { address: &#39;10.2.0.231&#39;, family: &#39;IPv4&#39;, internal: false } ] }</code></pre>
<h2>os.EOL<span><a class="mark" href="#os_os_eol" id="os_os_eol">#</a></span></h2>
<p>A constant defining the appropriate End-of-line marker for the operating system.
</p>

          </div>
        </div>
    </div>
    </div>
    <div id="footer">
      <div class="foot-1">
        <a href="http://www.joyent.com"><h5>The Node.js Project is Sponsored by</h5>
        <img src="assets/joyent-footer.svg" width="200">
        <p class="tag">Production Node +<br>High Performance Infrastructure</p></a>
        <a href="https://my.joyent.com/landing/signup/701800000015696" class="button getstarted">Get Started</a>
      </div>
      <div class="foot-2">
        <div class="foot-nav">
          <ul>
            <li><a href="http://nodejs.org/download/">Downloads</a></li>
          </ul>
          <ul>
            <li><a href="http://nodejs.org/documentation/">Documentation</a></li>
            <li><a href="http://nodejs.org/api/">API Docs</a></li>
            <li><a href="http://nodejs.org/documentation/tutorials/">Tutorials</a></li>
            <li><a href="http://nodejs.org/documentation/localization/">Localization</a></li>
          </ul>
          <ul>
            <li><a href="http://nodejs.org/community/">Community</a></li>
            <li><a href="https://github.com/joyent/node/issues">Github Issues</a></li>
            <li><a href="http://groups.google.com/group/nodejs">Mailing List</a></li>
            <li><a href="http://webchat.freenode.net/?channels=node.js">IRC</a></li>
            <li><a href="https://twitter.com/nodejs">Twitter</a></li>
          </ul>
          <ul>
            <li><a href="http://nodejs.org/about/">About</a></li>
            <li><a href="http://nodejs.org/about/organization/">Organization</a></li>
            <li><a href="http://nodejs.org/about/core-team/">Core Team</a></li>
            <li><a href="http://nodejs.org/about/resources/">Resources</a></li>
          </ul>
          <ul>
            <li><a href="http://blog.nodejs.org">Blog</a></li>
          </ul>
        </div>
        <p class="copyright">Copyright 2014 <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="https://nodejs.org/images/trademark-policy.pdf">trademark</a> of Joyent, Inc. <a href="https://raw.github.com/joyent/node/v0.10.35/LICENSE">View license</a>.</p>
      </div>
    </div>

  <script src="/sh_main.js"></script>
  <script src="/sh_javascript.min.js"></script>
  <script>highlight(undefined, undefined, 'pre');</script>
  <script>
    window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
    (function(d, t) {
      var g = d.createElement(t),
          s = d.getElementsByTagName(t)[0];
      g.src = '//www.google-analytics.com/ga.js';
      s.parentNode.insertBefore(g, s);
    }(document, 'script'));
  </script>
</body>
</html>

